package com.jcoinexchange.market.business.dubbo;

import com.jcoinexchange.market.common.vo.WSBasicResponse;
import com.jcoinexchange.market.infra.ws.WSServer;
import com.jexchange.dubboapi.req.ws.WsMarketDubboReq;
import com.jexchange.dubboapi.service.market.WsPushDubboService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class WsPushDubboServiceImpl implements WsPushDubboService {

    @Autowired
    private WSServer wsServer;


    @Override
    public boolean market(WsMarketDubboReq req) {
        Long memberId = req.getMemberId();
        Long orderId = req.getOrderId();
        if (memberId != null) {
            WSBasicResponse orderWSBasicResponse = new WSBasicResponse();
            orderWSBasicResponse.setType(3);
            orderWSBasicResponse.setData(orderId.toString());
            wsServer.sendMsg(memberId.toString(), orderWSBasicResponse);
        }
        WSBasicResponse WSBasicResponse = new WSBasicResponse();
        WSBasicResponse.setType(2);
        WSBasicResponse.setData(req.getData());
        return wsServer.full(WSBasicResponse);
    }
}
